using System.Data;
using System.Data.SqlClient;
using Customs.Components.KDT.Khac.Info;
using Microsoft.ApplicationBlocks.Data;

namespace Customs.Components.KDT.Khac
{
	public class HangMauDich : HangMauDichInfo
	{
		//---------------------------------------------------------------------------------------------
		public void Load(HangMauDichInfo entityInfo)
		{
			this._SoThuTuHang = entityInfo.SoThuTuHang;
			this._MaHS = entityInfo.MaHS;
			this._MaPhu = entityInfo.MaPhu;
			this._TenHang = entityInfo.TenHang;
			this._NuocXX_ID = entityInfo.NuocXX_ID;
			this._DVT_ID = entityInfo.DVT_ID;
			this._SoLuong = entityInfo.SoLuong;
            this._MA_NPL_SP = entityInfo.MA_NPL_SP;
			this._DonGiaKB = entityInfo.DonGiaKB;
			this._DonGiaTT = entityInfo.DonGiaTT;
			this._TriGiaKB = entityInfo.TriGiaKB;
			this._TriGiaTT = entityInfo.TriGiaTT;
			this._TriGiaKB_VND = entityInfo.TriGiaKB_VND;
			this._ThueSuatXNK = entityInfo.ThueSuatXNK;
			this._ThueSuatTTDB = entityInfo.ThueSuatTTDB;
			this._ThueSuatGTGT = entityInfo.ThueSuatGTGT;
			this._ThueXNK = entityInfo.ThueXNK;
			this._ThueTTDB = entityInfo.ThueTTDB;
			this._ThueGTGT = entityInfo.ThueGTGT;
			this._PhuThu = entityInfo.PhuThu;
			this._TyLeThuKhac = entityInfo.TyLeThuKhac;
			this._TriGiaThuKhac = entityInfo.TriGiaThuKhac;
			this._MienThue = entityInfo.MienThue;            
		    this._SoTiepNhan = entityInfo.SoTiepNhan;
		    this._MaHaiQuan = entityInfo.MaHaiQuan;            
		    this._NamTiepNhan = entityInfo.NamTiepNhan;
            this._maDG = "HD";
		}

		//---------------------------------------------------------------------------------------------

		public int Insert(SqlTransaction transaction)
		{
			string spName = "INSERT INTO DHANGMD "+
	        "( "+
		    "So_TNDKDT, "+
		    "Ma_HQTN, "+
		    "Nam_TN, "+
		    "STTHang, "+
		    "MA_NPL_SP, "+
		    "MaHang_KB, "+
		    "Ma_Hang, "+
		    "Ma_Phu, "+
		    "Ten_Hang, "+
		    "Nuoc_XX, "+
		    "Ma_DVT, "+
		    "Luong, "+
		    "DGia_KB,"+
		    "DGia_TT, "+
		    "Ma_DG,"+
		    "TriGia_KB, "+
		    "TriGia_TT, "+
		    "TGKB_VND, "+
		    "LoaiTSXNK, "+
		    "TS_XNK, "+
		    "TS_TTDB, "+
		    "TS_VAT, "+
		    "Thue_XNK, "+
		    "Thue_TTDB, "+
		    "Thue_VAT, "+
		    "Phu_Thu, "+
		    "MienThue, "+
		    "Tyle_ThuKhac, "+
		    "TriGia_ThuKhac "+
	        ") "+
	        "VALUES "+
	        "( "+
		        "@SoTiepNhan, "+
		        "@MaHaiQuan, "+
		        "@NamTiepNhan, "+
		        "@SoThuTuHang,"+
		        "@MaPhu, "+
		        "@MaHS, "+
		        "@MaHS, "+
		        "@MaPhu, "+
		        "@TenHang, "+
		        "@NuocXX_ID, "+
		        "@DVT_ID, "+
		        "@SoLuong,					 "+
		        "@DonGiaKB, "+
		        "@DonGiaTT,					 "+
		        "@Ma_DG,						 "+
		        "@TriGiaKB, "+
		        "@TriGiaTT, "+
		        "@TriGiaKB_VND, "+
		        "null,						 "+
		        "@ThueSuatXNK, "+
		        "@ThueSuatTTDB, "+
		        "@ThueSuatGTGT, "+
		        "@ThueXNK, "+
		        "@ThueTTDB, "+
		        "@ThueGTGT, "+
		        "@PhuThu, "+
		        "@MienThue, "+
		        "@TyleThuKhac, "+
		        "@TriGiaThuKhac )";
			SqlParameter[] parameters = new SqlParameter[26];

			parameters[0] = new SqlParameter("@SoTiepNhan", SqlDbType.BigInt);
			parameters[0].Direction = ParameterDirection.Input;
			parameters[0].Value = this._SoTiepNhan;

			parameters[1] = new SqlParameter("@MaHaiQuan", SqlDbType.Char, 6);
			parameters[1].Direction = ParameterDirection.Input;
			parameters[1].Value = this._MaHaiQuan;

            parameters[2] = new SqlParameter("@NamTiepNhan", SqlDbType.SmallInt);
            parameters[2].Direction = ParameterDirection.Input;
            parameters[2].Value = this._NamTiepNhan;

			parameters[3] = new SqlParameter("@SoThuTuHang", SqlDbType.Int);
			parameters[3].Direction = ParameterDirection.Input;
			parameters[3].Value = this._SoThuTuHang;

			parameters[4] = new SqlParameter("@MaHS", SqlDbType.VarChar);
			parameters[4].Size = 12;
			parameters[4].Direction = ParameterDirection.Input;
			parameters[4].Value = this._MaHS;

			parameters[5] = new SqlParameter("@MaPhu", SqlDbType.VarChar);
			parameters[5].Size = 30;
			parameters[5].Direction = ParameterDirection.Input;
			parameters[5].Value = this._MaPhu;

			parameters[6] = new SqlParameter("@TenHang", SqlDbType.NVarChar);
			parameters[6].Size = 80;
			parameters[6].Direction = ParameterDirection.Input;
			parameters[6].Value = this._TenHang;

			parameters[7] = new SqlParameter("@NuocXX_ID", SqlDbType.Char);
			parameters[7].Size = 3;
			parameters[7].Direction = ParameterDirection.Input;
			parameters[7].Value = this._NuocXX_ID;

			parameters[8] = new SqlParameter("@DVT_ID", SqlDbType.Char);
			parameters[8].Size = 3;
			parameters[8].Direction = ParameterDirection.Input;
			parameters[8].Value = this._DVT_ID;

			parameters[9] = new SqlParameter("@SoLuong", SqlDbType.Decimal);
			parameters[9].Precision = 18;
			parameters[9].Scale = 3;
			parameters[9].Direction = ParameterDirection.Input;
			parameters[9].Value = this._SoLuong;

            parameters[10] = new SqlParameter("@Ma_DG", SqlDbType.Char);
            parameters[10].Size = 10;
			parameters[10].Direction = ParameterDirection.Input;
			parameters[10].Value = this._maDG;

			parameters[11] = new SqlParameter("@DonGiaKB", SqlDbType.Float);
			parameters[11].Direction = ParameterDirection.Input;
			parameters[11].Value = this._DonGiaKB;

            parameters[12] = new SqlParameter("@DonGiaTT", SqlDbType.Float);
			parameters[12].Direction = ParameterDirection.Input;
			parameters[12].Value = this._DonGiaTT;

            parameters[13] = new SqlParameter("@TriGiaKB", SqlDbType.Float);
			parameters[13].Direction = ParameterDirection.Input;
			parameters[13].Value = this._TriGiaKB;

            parameters[14] = new SqlParameter("@TriGiaTT", SqlDbType.Float);
			parameters[14].Direction = ParameterDirection.Input;
			parameters[14].Value = this._TriGiaTT;

            parameters[15] = new SqlParameter("@TriGiaKB_VND", SqlDbType.Float);
			parameters[15].Direction = ParameterDirection.Input;
			parameters[15].Value = this._TriGiaKB_VND;

            parameters[16] = new SqlParameter("@ThueSuatXNK", SqlDbType.Float);
			parameters[16].Direction = ParameterDirection.Input;
			parameters[16].Value = this._ThueSuatXNK;

            parameters[17] = new SqlParameter("@ThueSuatTTDB", SqlDbType.Float);
			parameters[17].Direction = ParameterDirection.Input;
			parameters[17].Value = this._ThueSuatTTDB;

            parameters[18] = new SqlParameter("@ThueSuatGTGT", SqlDbType.Float);
			parameters[18].Direction = ParameterDirection.Input;
			parameters[18].Value = this._ThueSuatGTGT;

            parameters[19] = new SqlParameter("@ThueXNK", SqlDbType.Float);
			parameters[19].Direction = ParameterDirection.Input;
			parameters[19].Value = this._ThueXNK;

            parameters[20] = new SqlParameter("@ThueTTDB", SqlDbType.Float);
			parameters[20].Direction = ParameterDirection.Input;
			parameters[20].Value = this._ThueTTDB;

            parameters[21] = new SqlParameter("@ThueGTGT", SqlDbType.Float);
			parameters[21].Direction = ParameterDirection.Input;
			parameters[21].Value = this._ThueGTGT;

            parameters[22] = new SqlParameter("@PhuThu", SqlDbType.Float);
		    parameters[22].Direction = ParameterDirection.Input;
			parameters[22].Value = this._PhuThu;

			parameters[23] = new SqlParameter("@TyLeThuKhac", SqlDbType.Decimal);
			parameters[23].Precision = 5;
			parameters[23].Scale = 2;
			parameters[23].Direction = ParameterDirection.Input;
			parameters[23].Value = this._TyLeThuKhac;

            parameters[24] = new SqlParameter("@TriGiaThuKhac", SqlDbType.Float);
			parameters[24].Direction = ParameterDirection.Input;
			parameters[24].Value = this._TriGiaThuKhac;

			parameters[25] = new SqlParameter("@MienThue", SqlDbType.TinyInt);
			parameters[25].Direction = ParameterDirection.Input;
			parameters[25].Value = this._MienThue;

			return SqlHelper.ExecuteNonQuery(transaction, CommandType.Text, spName, parameters);
			
		}
	}
}